home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_windowmaker.idb / usr / freeware / bin / wmaker.inst.z / wmaker.inst
Encoding:
Text File  |  1999-07-16  |  7.5 KB  |  322 lines

  1. #!/bin/sh
  2. #
  3. # Install Window Maker for the current user
  4. #
  5.  
  6. # xx herbert
  7. if test x"$1" = x"--batch" ; then
  8.   BATCH="1"
  9. else
  10.   BATCH=""
  11. fi
  12. # /xx herbert
  13.  
  14. # directory where system wide configuration is stored
  15. GLOBALDIR="/usr/freeware/share/WindowMaker"
  16. GLOBALDEFDIR="/usr/freeware/etc/WindowMaker"
  17.  
  18. USERDIR=$HOME
  19.  
  20. VERSION="0.52.0"
  21.  
  22. BINDIR="/usr/freeware/bin"
  23.  
  24. make_dir() {
  25.     mkdir $1
  26.     chmod +rwx $1
  27. }
  28.  
  29. make_script() {
  30.     ISCRIPT=$1
  31.  
  32.     cat << EOF >> $ISCRIPT
  33. # Window Maker default X session startup script 
  34.  
  35. PATH="\$PATH:$BINDIR"
  36.  
  37. # If you login from xdm, uncomment this to make error messages appear
  38. # in the console window.
  39. #
  40. # tail -f $HOME/.xsession-errors > /dev/console &
  41.  
  42. exec wmaker
  43.  
  44. EOF
  45.     chmod +rx $ISCRIPT
  46. }
  47.  
  48.  
  49. #
  50. # Copy files considering special cases
  51. #
  52. copy() {
  53.     source=$1
  54.     target=$2
  55.     file=`basename $source`
  56.     rm -f $target
  57.     if [ "$file" = "WMRootMenu" ]; then
  58.         echo \"$GSDIR/Library/WindowMaker/menu\" > \
  59.             $target
  60.     elif [ "$file" = "WindowMaker" ]; then
  61.         sed -e "s|~/GNUstep|$GSDIR|g" $source > $target
  62.     else
  63.         if test "x$GNUSTEP_USER_ROOT" = "x"; then
  64.             sed -e "s:#wmdatadir#:$GLOBALDIR:g" \
  65.                     $source > $target
  66.         else
  67.             sed -e "s|\$HOME/GNUstep|$GSDIR|g" \
  68.                 -e "s:#wmdatadir#:$GLOBALDIR:g" \
  69.                     $source > $target
  70.         fi
  71.     fi
  72. }
  73.  
  74.  
  75.  
  76. echo "Installing WindowMaker $VERSION for current user..."
  77.  
  78.  
  79. if [ ! -d $GLOBALDIR ]; then
  80.       echo "Could not find global data files"
  81.       echo "Make sure you have installed Window Maker correctly"
  82.       exit 1
  83. fi
  84.  
  85. if [ ! -d $GLOBALDEFDIR ]; then
  86.       echo "Could not find global configurations files"
  87.       echo "Make sure you have installed Window Maker correctly"
  88.       exit 1
  89. fi
  90.  
  91. if [ ! -d "$USERDIR" ]; then
  92.       echo "Could not find user directory $USERDIR"
  93.       exit 1
  94. fi
  95.  
  96.  
  97. if test "x$GNUSTEP_USER_ROOT" = "x"; then
  98.     cd $USERDIR
  99.     GSDIR=$USERDIR/GNUstep
  100.     if [ ! -d $GSDIR ]; then
  101.         echo "Creating $GSDIR user directory"
  102.         make_dir $GSDIR
  103.     fi
  104. else
  105.     GSDIR=$GNUSTEP_USER_ROOT
  106.     if [ ! -d $GSDIR ]; then
  107.         echo "Directory specified in GNUSTEP_USER_ROOT environment variable does not exist"
  108.         exit 1
  109.     fi
  110.     cd $GSDIR
  111.     cd ..
  112. fi
  113.  
  114.  
  115. if [ ! -d "$GSDIR/.AppInfo" ]; then
  116.     make_dir $GSDIR/.AppInfo
  117. fi
  118.  
  119. if [ ! -d "$GSDIR/Defaults" ]; then
  120.     make_dir $GSDIR/Defaults
  121. fi
  122.  
  123. echo "Copying defaults database..."
  124.  
  125. FILES=`(cd $GLOBALDEFDIR;ls *)`
  126. all=""
  127. for i in $FILES; do
  128. # xx herbert
  129.     if [ -f $GSDIR/Defaults/$i -a -z "$BATCH" ]; then
  130. # /xx herbert
  131.         echo "The configuration file \"$i\" already exists in your defaults database."
  132.         echo "Do you wish to replace it? <y/n/a> [n] $all"
  133.         if [ "$all" != "a" ]; then
  134.             read foo
  135.             if [ "$foo" = "a" -o "$foo" = "A" ]; then
  136.                 all="a"
  137.             fi
  138.         fi
  139.         if [ "$foo" = "y" -o "$foo" = "Y" -o "$all" = "a" ]; then
  140.             copy $GLOBALDEFDIR/$i $GSDIR/Defaults/$i
  141.         fi
  142.     else
  143.         copy $GLOBALDEFDIR/$i $GSDIR/Defaults/$i
  144.     fi
  145. done
  146.  
  147.  
  148. if [ ! -d "$GSDIR/Library/Icons/" ]; then
  149.       echo "Creating icon library directory $GSDIR/Library/Icons"
  150.       if [ ! -d $GSDIR/Library ]; then
  151.               make_dir $GSDIR/Library
  152.       fi
  153.       make_dir $GSDIR/Library/Icons
  154. fi
  155.  
  156.  
  157. if [ ! -d "$GSDIR/Library/WindowMaker/" ]; then
  158.       echo "Creating WindowMaker data library directory $GSDIR/Library/WindowMaker"
  159.       if [ ! -d $GSDIR/Library ]; then
  160.               make_dir $GSDIR/Library
  161.       fi
  162.       make_dir $GSDIR/Library/WindowMaker
  163. fi
  164.  
  165. if [ ! -d "$GSDIR/Library/WindowMaker/Styles" ]; then
  166.     echo "Creating style library $GSDIR/Library/WindowMaker/Styles"
  167.     make_dir $GSDIR/Library/WindowMaker/Styles
  168. fi
  169.  
  170.  
  171. if [ ! -d "$GSDIR/Library/WindowMaker/Themes" ]; then
  172.     echo "Creating theme library $GSDIR/Library/WindowMaker/Themes"
  173.     make_dir  $GSDIR/Library/WindowMaker/Themes
  174. fi
  175.  
  176.  
  177.  
  178. if [ ! -d "$GSDIR/Library/WindowMaker/Backgrounds" ]; then
  179.     echo "Creating bg image library $GSDIR/Library/WindowMaker/Backgrounds"
  180.     make_dir  $GSDIR/Library/WindowMaker/Backgrounds
  181. else
  182.     echo "Default Backgrounds directory already exists. Skipping..."
  183. fi
  184.  
  185.  
  186. if [ ! -d "$GSDIR/Library/WindowMaker/IconSets" ]; then
  187.     echo "Creating icon setup library $GSDIR/Library/WindowMaker/IconSets"
  188.     make_dir  $GSDIR/Library/WindowMaker/IconSets
  189. else
  190.     echo "Default IconSets directory already exists. Skipping..."
  191. fi
  192.  
  193.  
  194. if [ ! -d "$GSDIR/Library/WindowMaker/Pixmaps" ]; then
  195.     echo "Creating pixmap library $GSDIR/Library/WindowMaker/Pixmaps"
  196.     make_dir  $GSDIR/Library/WindowMaker/Pixmaps
  197. else
  198.     echo "Default Pixmaps directory already exists. Skipping..."
  199. fi
  200.  
  201.  
  202. if [ ! -d "$GSDIR/Library/WindowMaker/Sounds" ]; then
  203.     echo "Creating sound library $GSDIR/Library/WindowMaker/Sounds"
  204.     make_dir  $GSDIR/Library/WindowMaker/Sounds
  205. else
  206.     echo "Default Sounds directory already exists. Skipping..."
  207. fi
  208.  
  209.  
  210. if [ ! -d "$GSDIR/Library/WindowMaker/SoundSets" ]; then
  211.     echo "Creating sound set library $GSDIR/Library/WindowMaker/SoundSets"
  212.     make_dir  $GSDIR/Library/WindowMaker/SoundSets
  213. else
  214.     echo "Default SoundSets directory already exists. Skipping..."
  215. fi
  216.  
  217.  
  218. if test -z "" ; then
  219. FILES=`(cd $GLOBALDIR; ls menu menu.* plmenu plmenu.?? wmmacros)`
  220. for i in $FILES; do
  221. # xx herbert
  222.     if [ -f "$GSDIR/Library/WindowMaker/$i" -a -z "$BATCH" ]; then
  223. # /xx herbert
  224.         echo "The file \"$i\" already exists in $GSDIR/Library/WindowMaker"
  225.         echo "Do you wish to replace it? <y/n/a> [n] $all"
  226.         if [ "$all" != "a" ]; then
  227.             read foo
  228.             if [ "$foo" = "a" -o "$foo" = "A" ]; then
  229.                 all="a"
  230.             fi
  231.         fi
  232.         if [ "$foo" = "y" -o "$foo" = "Y" -o "$foo" = "a" ]; then
  233.             copy $GLOBALDIR/$i $GSDIR/Library/WindowMaker/$i
  234.         fi
  235.     else
  236.         copy $GLOBALDIR/$i $GSDIR/Library/WindowMaker/$i
  237.     fi
  238. done
  239. fi
  240.  
  241. cp $GLOBALDIR/README.themes $GSDIR/Library/WindowMaker 
  242. cp $GLOBALDIR/README $GSDIR/Library/WindowMaker
  243.  
  244. test -f ~$GSDIR/Library/WindowMaker/autostart || \
  245.     cp $GLOBALDIR/autostart.sh $GSDIR/Library/WindowMaker/autostart
  246. chmod +rx $GSDIR/Library/WindowMaker/autostart
  247.  
  248. test -f ~$GSDIR/Library/WindowMaker/exitscript || \
  249.     cp $GLOBALDIR/exitscript.sh $GSDIR/Library/WindowMaker/exitscript
  250. chmod +rx $GSDIR/Library/WindowMaker/exitscript
  251.  
  252. # xx herbert
  253. if test -n "$BATCH" ; then
  254.   echo "Installation Finished"
  255.   exit 0
  256. fi
  257. # /xx herbert
  258.  
  259.  
  260. #
  261. #######################
  262.  
  263. DATE=`date +%b%d.%T`
  264.  
  265. show_end_message() {
  266.  
  267. echo
  268. echo "Installation Finished"
  269. echo
  270. if test -z "" ; then
  271.  echo "There are menus in 2 different file formats. The plain text format and"
  272.  echo "the property list format. The plain text format is more flexible, but"
  273.  echo "the menu in the property list format can be edited graphically. The"
  274.  echo "menu that will be used by default is the plain text. Read"
  275.  echo "$GSDIR/Library/WindowMaker/README for information on how to change it."
  276. else
  277.  echo "Your copy of Window Maker is configured especially for KDE."
  278.  echo "Window Maker application menus are not available."
  279. fi
  280. }
  281.  
  282. wmaker_found=0
  283. for xinit in .xinitrc .Xclients .xsession; do
  284.      test ! -f "$HOME/$xinit" && continue
  285.      res="`grep wmaker $HOME/$xinit`"
  286.      if test "x$res" != x; then
  287.          wmaker_found=1
  288.     break
  289.      fi
  290. done
  291. if test $wmaker_found = 1; then
  292.     echo "Found Window Maker to already be your default window manager."
  293.     show_end_message
  294.     exit 0
  295. fi
  296.  
  297.  
  298. trap "show_end_message;exit" 2
  299.  
  300. echo
  301. echo "Now the .xinitrc, .Xclients or .xsession script must be updated so that"
  302. echo "it calls wmaker when you start an X session."
  303. echo "Type the name of the file that must be changed (normally .xinitrc)."
  304. echo "If the file already exists, it will be backed up with a .old.$DATE "
  305. echo "extension"
  306. echo "If you want to edit it by hand, hit <Control>-C now."
  307. read file
  308.  
  309. if test "x$file" = "x"; then
  310.     echo "Using .xinitrc as a default value"
  311.     file=.xinitrc
  312. fi
  313.  
  314. if [ -f $USERDIR/$file ]; then
  315.     mv $USERDIR/$file $USERDIR/$file.old.$DATE
  316. fi
  317.  
  318. make_script $USERDIR/$file
  319.  
  320. show_end_message
  321.  
  322.